﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace GrayParrot.ServiceProcess
{
    public class Starter
    {
        public Starter()
        {

        }

        public static bool Start(string[] args, string location)
        {
            bool retValue = false;

            if (args.Length > 0) 
            {
                // InstallHelper, in the System.Configuration.Install.ManagedInstallerClass class. 
                // By using this method, I can install or uninstall the service from the command line.
             
                //Installs the Service 
                if (args[0].Trim(). ToLower()== "/i") {
                  System.Configuration.Install.ManagedInstallerClass.InstallHelper(new string[] { "/i", location });
                } //Uninstalls the service 
                else if (args[0].Trim(). ToLower() == "/u") {
                  System.Configuration.Install.ManagedInstallerClass.InstallHelper(new string[] { "/u", location });
                }

                retValue = true;
            }

            return retValue;
        }
    }
}
